home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15217 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question about C compiler
  5. Date: 17 Apr 1996 16:34:40 -0500
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4l3o5g$bso@solutions.solon.com>
  8. References: <1996Apr16.175344.6042@lafn.org> <16APR199620514504@erich.triumf.ca>
  9. Reply-To: seebs@solon.com
  10. NNTP-Posting-Host: solutions.solon.com
  11.  
  12. In article <16APR199620514504@erich.triumf.ca>,
  13. P.Bennett <bennett@erich.triumf.ca> wrote:
  14. >free(ptr) does not change ptr, or the memory ptr points to - it just "marks"
  15. >the memory as available for future malloc()s.
  16.  
  17. This is not always true, it is merely the most common implementation.
  18.  
  19. >After you do free(ptr) you can (but shouldn't) access the "freed" memory,
  20. >and the data previously stored in it, providing a later malloc() has not used
  21. >the space.
  22.  
  23. This is specifically untrue; some implementations flag the memory such that
  24. an attempt to access it may die screaming.
  25.  
  26. ANSI says that the value of a pointer to freed space is
  27. indeterminate, so an implementation has license to run
  28. through and set all pointers to the space to NULL,
  29. unlikely though this would be.
  30.  
  31. -s
  32. -- 
  33. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  34. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  35. Unsolicited email is not welcome, and will be billed for at consulting rates.
  36. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  37.